<template>
  <div>
    <el-table :data="transportData.records">
      <el-table-column label="车次" prop="transportTripsName" fixed="left"/>
      <el-table-column label="车辆品牌" prop="truckName"/>
      <el-table-column label="调度机构" prop="startAgencyName"/>
      <el-table-column label="起始地" prop="startAgencyName"/>
      <el-table-column label="目的地" prop="endAgencyName"/>
      <el-table-column label="运输任务状态" prop="status">
        <template slot-scope="scope">
          <p v-if="scope.row.status==1">未发车</p>
          <p v-if="scope.row.status==2">进行中</p>
          <p v-if="scope.row.status==3">为待确认</p>
          <p v-if="scope.row.status==4">已完成</p>
          <p v-if="scope.row.status==5">已取消</p>
        </template>
      </el-table-column>
      <el-table-column label="任务分配状态" prop="assignedStatus">
        <template slot-scope="scope">
          <p v-if="scope.row.assignedStatus==1">未分配</p>
          <p v-if="scope.row.assignedStatus==2">已分配</p>
          <p v-if="scope.row.assignedStatus==3">待人工分配</p>
        </template>
      </el-table-column>
      <el-table-column label="车载状态" prop="loadingStatus">
        <template slot-scope="scope">
          <p v-if="scope.row.loadingStatus==1">半载</p>
          <p v-if="scope.row.loadingStatus==2">满载</p>
          <p v-if="scope.row.loadingStatus==3">空载</p>
        </template>
      </el-table-column>
      <el-table-column label="计划提货时间" prop="planPickUpGoodsTime"/>
      <el-table-column label="实际提货时间" prop="actualPickUpGoodsTime"/>
      <el-table-column label="计划发车时间" prop="planDepartureTime"/>
      <el-table-column label="实际发车时间" prop="actualDepartureTime"/>
      <el-table-column label="创建时间" prop="createTime"/>
      <el-table-column label="操作" width="120">
        <template slot-scope="scope">
          <el-button type="primary" size="mini">
            <router-link :to="'/transport-info-details/'+scope.row.id">
              <b style="color: white">查看运输任务详情</b>
            </router-link>
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--    分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="Number(transportData.current)"
      :page-sizes="[5, 10, 30, 50]"
      :page-size="Number(transportData.size)"
      layout="total, sizes, prev, pager, next, jumper"
      :total="Number(transportData.total)"
    >
    </el-pagination>
  </div>
</template>

<script>
import index from '@/api/transport/index'

export default {
  name: 'index',
  data() {
    return {
      transportData: {},
      pageNum: 1,
      pageSize: 5
    }
  }, methods: {
    handleSizeChange(val) {
      this.pageSize = val
      this.findTransportPage()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.findTransportPage()
    },
    findTransportPage() {
      index.findTransportPage(this.pageNum, this.pageSize).then(data => {
        this.transportData = data.data
      }).catch(e => {

      })
    }
  }, mounted() {
    this.findTransportPage()
  }
}
</script>

<style scoped>

</style>
